/*
 * @Date         : 2022-06-10 09:53:11
 * @LastEditors  : zu1662
 * @LastEditTime : 2022-07-21 15:46:09
 * @Description  : User Entity
 * 
 * Copyright © 2022 by zu1662, All Rights Reserved. 
 */
import { ApiProperty } from '@nestjs/swagger';
import { Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm';

@Entity({ name: 'user' })
export class UserEntity {

  @PrimaryGeneratedColumn('uuid')
  id: string;

  @ApiProperty()
  @Column({ length: 50, charset: 'utf8mb4' })
  name: string;

  @ApiProperty()
  @Column({ length: 500 })
  password: string;

  @ApiProperty()
  @Column({ length: 500, default: null })
  avatar: string; // 头像

  @ApiProperty()
  @Column({ length: 500, default: null })
  email: string; // 邮箱
  
  @ApiProperty()
  @Column({ length: 11, default: null })
  phone: string; // 手机号

  @ApiProperty()
  @Column('simple-enum', { enum: ['admin', 'visitor'], default: 'visitor' })
  role: string; // 用户角色

  @ApiProperty()
  @Column('simple-enum', { enum: ['locked', 'active'], default: 'active' })
  status: string; // 用户状态

  @ApiProperty()
  @Column({ default: 'normal' })
  type: string; // 用户类型

  @ApiProperty()
  @CreateDateColumn({
    type: 'datetime',
    comment: '创建时间',
    name: 'create_at',
  })
  createAt: Date;

  @ApiProperty()
  @UpdateDateColumn({
    type: 'datetime',
    comment: '更新时间',
    name: 'update_at',
  })
  updateAt: Date;
}
